<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>注册页面</title>
    <link rel="icon" href="${ pageContext.request.contextPath}/assets/images/favicon.ico" type="image/ico">
    <link href="${ pageContext.request.contextPath}/assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="${ pageContext.request.contextPath}/assets/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="${ pageContext.request.contextPath}/assets/css/style.css" rel="stylesheet">
    <script type="text/javascript" src="${ pageContext.request.contextPath}/assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="${ pageContext.request.contextPath}/assets/js/jquery.min.js"></script>
     <script>
        var ctx = '${ pageContext.request.contextPath}';
        console.log("ctx:"+ctx)
    </script>
    <script type="text/javascript" src="${ pageContext.request.contextPath}/assets/theme.js"></script>
    <style>
        .lyear-wrapper {
            position: relative;
        }
        .lyear-login {
            display: flex !important;
            min-height: 100vh;
            align-items: center !important;
            justify-content: center !important;
        }
        .lyear-login:after{
            content: '';
            min-height: inherit;
            font-size: 0;
        }
        .login-center {
            background: #FFFFFFAA;
            min-width: 29.25rem;
            padding: 2.14286em 3.57143em;
            border-radius: 3px;
            margin: 2.85714em;
        }
    </style>
<script>
        $(document).ready(function() {
            // 绑定表单的提交事件
            $("#form").submit(function(event) {
                // 阻止表单的默认提交行为
                event.preventDefault();
                // 调用校验密码的方法
                if (checkPwd()) {
                    // 如果校验通过，则手动提交表单
                    this.submit();
                }
            });
        });
        function checkPwd() {
            var password = $("#password").val();
            var password2 = $("#password2").val();
            if (password !== password2) {
                alert("两次密码不一致");
                return false;
            }
            return true;
        }
    </script>
</head>

<body>
<div class="row lyear-wrapper loginBg" >
  <div class="lyear-login">
    <div class="login-center">
      <form id="form" action="${ pageContext.request.contextPath}/register" method="post">
        <div class="form-group ">
          <input required maxlength="12" type="text" placeholder="请输入您的用户名" class="form-control" name="username" id="username" />
        </div>
        <div class="form-group ">
          <input required type="password" placeholder="请输入密码" class="form-control" id="password" name="password" />
        </div>
        <div class="form-group ">
          <input required type="password" placeholder="确认密码" class="form-control" id="password2" name="password2" />
        </div>
        <div class="form-group">
          <select class="form-control" name="usertype" >
            <option value="">请选择注册角色</option>
            <option value="user">用户</option>
          </select>
        </div>
        
        <div class="form-group">
          <button class="btn btn-block btn-primary" type="submit">注册</button>
        </div>
        <footer class="text-center">
        <p class="m-b-0">已有账号？<a href="login.jsp">立即登陆</a></p>
        </footer>
        <c:if test="${ not empty message}">
          <div class="alert alert-danger" role="alert">${ message}</div>
        </c:if>
      </form>
      <hr>
      
    </div>
  </div>
</div>
</body>
</html>

